Flush the GIC driver data after init
authorSoby Mathew <[email protected]>
Tue, 14 Feb 2017 10:11:52 +0000 (10:11 +0000)
committerSoby Mathew <[email protected]>
Wed, 1 Mar 2017 14:38:28 +0000 (14:38 +0000)
The GIC driver data is initialized by the primary CPU with caches
enabled. When the secondary CPU boots up, it initializes the
GICC/GICR interface with the caches disabled and there is a chance that
the driver data is not yet written back to the memory. This patch fixes
this problem by flushing the driver data after they have been
initialized.

Change-Id: Ie9477029683846209593ff005d2bac559bb8f5e6
Signed-off-by: Soby Mathew <[email protected]>
drivers/arm/gic/v2/gicv2_main.c
drivers/arm/gic/v3/gicv3_main.c

index 305a8b07cac52ee62ad4ef7d38f3a1dc787d9356..fcc4b8b78a634fa1861c4cbc1a06c1fee9f5d122 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -158,6 +158,17 @@ void gicv2_driver_init(const gicv2_driver_data_t *plat_driver_data)
 
        driver_data = plat_driver_data;
 
+       /*
+        * The GIC driver data is initialized by the primary CPU with caches
+        * enabled. When the secondary CPU boots up, it initializes the
+        * GICC/GICR interface with the caches disabled. Hence flush the
+        * driver_data to ensure coherency. This is not required if the
+        * platform has HW_ASSISTED_COHERENCY enabled.
+        */
+#if !HW_ASSISTED_COHERENCY
+       flush_dcache_range((uintptr_t) &driver_data, sizeof(driver_data));
+       flush_dcache_range((uintptr_t) driver_data, sizeof(*driver_data));
+#endif
        INFO("ARM GICv2 driver initialized\n");
 }
 
index 5abaa1ce36914ca818d6dd38e37f87e5dbbd6c3e..2efab4c8d99aa0eddf824cdd7da5c6025590b5a6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -116,6 +116,18 @@ void gicv3_driver_init(const gicv3_driver_data_t *plat_driver_data)
 
        driver_data = plat_driver_data;
 
+       /*
+        * The GIC driver data is initialized by the primary CPU with caches
+        * enabled. When the secondary CPU boots up, it initializes the
+        * GICC/GICR interface with the caches disabled. Hence flush the
+        * driver_data to ensure coherency. This is not required if the
+        * platform has HW_ASSISTED_COHERENCY enabled.
+        */
+#if !HW_ASSISTED_COHERENCY
+       flush_dcache_range((uintptr_t) &driver_data, sizeof(driver_data));
+       flush_dcache_range((uintptr_t) driver_data, sizeof(*driver_data));
+#endif
+
        INFO("GICv3 %s legacy support detected."
                        " ARM GICV3 driver initialized in EL3\n",
                        gicv2_compat ? "with" : "without");